 <!--
* description: 备件明细详情
* author: chenweilin
* carryDate: 2021/7/15
-->

<template>
  <el-dialog
    v-dialogDrag
    :visible="dialogVisible"
    width="75%"
    :append-to-body="true"
    :close-on-click-modal="false"
    :show-close="true"
    :destroy-on-close="true"
    center
    @close="changeVisible()"
  >
    <dialogHeader
      slot="title"
      :title="'出库备件详情'"
      :style-type="$store.state.app.dialogType"
    />

    <one-table-template
      v-loading="loading"
      ref="multipleTable"
      :dynamic-components="tableComponents"
      :dynamic-table-cols="tableCols"
      :dynamic-form-fields="formField"
      :dynamic-table-defult-height="400"
      :dynamic-is-show-select="false"
      :dynamic-is-init-table="false"
      dynamic-table-ref="table"
      :dynamic-is-show-more-btn="true"
      :dynamic-is-fix-index="false"
      :is-show-pagination="false"
      :callback-obj="callbackObj"
    >
    </one-table-template>
  </el-dialog>
</template>

<script>
import dialogHeader from '@/components/dialogHeader'
import OneTableTemplate from '@/components/templates/oneTable'
export default {
  name: 'saleDeliveryEdit',
  components: {
    dialogHeader,
    OneTableTemplate
  },
  props: {
    editRowData: { type: Object, default: () => ({}) },    
  },
  data() {
    return {
      loading: false,
      saleOrderCode:null,
      dialogVisible:false,
      tableComponents: [],
      tableCols: [
        {
          prop: 'partNo',
          label: '备件编码'
        },
        {
          prop: 'partName',
          label: '备件名称'
        },
        {
          prop: 'outStoreQty',
          label: '出库数量+'          
        },
        {
          prop: 'salePrice',
          label: '出库单价',
        },
        {
            prop: 'saleAmount',
            label: '出库总金额',
        },
        {
          prop:'retrospectNo',
          label:'追溯件号'
        },
        {
          prop: 'remark',
          label: '备注'
        }
      ],
      formField: {

      },
      selections: [],
      callbackObj: {
        onCheckSelectChange: sel => {
          this.selections = sel
        }
      }
    }
  },
  methods: {
    selectAll() {
      this.selections = this.$utils.deepCopy(this.$refs['multipleTable'].list)
      this.$refs['multipleTable'].$refs['table'].toggleAllSelection()
    },
    setDefault() {
      this.$refs['multipleTable'].list.forEach(row => {
        row['pickingPersonName'] = this.editRowData.saName || ''
      })
    },
    open(id) {      
      this.$nextTick(async() => {
        const apiUrl = '/mp/e3sh/spareparts/nodestorehouse/dlrOutStorageService/queryOutStorageDetail.do'
        const variables = {
          outStoreCode: id
        }
        console.log(variables)
       
        let response
        try {
          response = await this.$requestAPI({ apiUrl, variables })
        } catch (e) { }
        if (response.result === '1') {
          this.$refs['multipleTable'].list = response.rows
          this.selectAll()
          this.setDefault()
        } else {
          this.$message(response.msg || '请求失败！')
        }
        // this.$refs['multipleTable'].listLoading = false
        // this.loading = false
      })        
    },
    changeVisible() {
        console.log('------调用')
        this.dialogVisible = false
    },
    outStoreQtyChange($event, row, col){},
  }
}
</script>

<style lang="css" scoped>

</style>
